/**
 * Created by Administrator on 2019/5/21 0021.
 */
import CZML_GENERALTOOLS_CLASS from "./../main/CZML_GENERALTOOLS_CLASS.js"
import CZML_CummunicationArc from "./CZML_CummunicationArc.js"
import CZML_PIXEL_CLASS from "../main/CZML_PIXEL_CLASS.js"
//
//
class CZML_NonAnimatedModel {
  //     constructor(viewer,id, name, OrbitStartTime, OrbitEndTime, position, orientation, ModelVisible, Model3DPath, ModelSize,
  //                 MarkerVisible, MarkerPath, MaekerPixelSize, MarkerColor, MarkerXOriginPos, MarkerYOriginPos,
  //                 OrbitVisible, OrbitLineStyle, OrbitLineWidth, OrbitColor, Distance){
  //         this._viewer=viewer;
  //         this.id=id;
  //         this.name=name;
  //         this.OrbitStartTime=OrbitStartTime;
  //         this.OrbitEndTime=OrbitEndTime;
  //         this.position=position;
  //         this.orientation=orientation;
  //         this.ModelVisible=ModelVisible;
  //         this.Model3DPath=Model3DPath;
  //         this.ModelSize=ModelSize;
  //         this.MarkerVisible=MarkerVisible;
  //         this.MarkerPath=MarkerPath;
  //         this.MaekerPixelSize=MaekerPixelSize;
  //         this.MarkerColor=MarkerColor;
  //         this.MarkerXOriginPos=MarkerXOriginPos;
  //         this.MarkerYOriginPos=MarkerYOriginPos;
  //         this.OrbitVisible=OrbitVisible;
  //         this.OrbitLineStyle=OrbitLineStyle;
  //         this.OrbitLineWidth=OrbitLineWidth;
  //         this.OrbitColor=OrbitColor;
  //         this.Distance=Distance;
  //         this.CZML_AddSpacecraft();
  //     }
  //     CZML_AddSpacecraft(){
  //     //??????????????
  //         CZML_GENERALTOOLS_CLASS.AddOrbitObject(this.id, this.name, this.OrbitStartTime, this.OrbitEndTime, this.position, this.orientation, this.ModelVisible, this.Model3DPath, this.ModelSize,
  //             this.MarkerVisible, this.MarkerPath, this.MaekerPixelSize, this.MarkerColor, this.MarkerXOriginPos, this.MarkerYOriginPos,
  //             this.OrbitLineStyle, this.OrbitLineWidth, this.OrbitColor, false, this.Distance);
  //         //?????????????
  //         var idOther = [null];
  //         var vOrbitStartTime = [this.OrbitStartTime];
  //         var vOrbitEndTime = [this.OrbitEndTime];
  //         var pixel = new CZML_PIXEL_CLASS(this._viewer);
  //         pixel.CZML_PIXEL_AddCummunicationArc(this.id, idOther, this.OrbitVisible, vOrbitStartTime, vOrbitEndTime);
  //         var OrbitObject = {
  //             "id": this.id,
  //             "availability": AvailabilityTime,
  //             "name": this.name,
  //             "billboard": {
  //                 "eyeOffset": {
  //                     "cartesian": [
  //                         0, 0, 0
  //                     ]
  //                 },
  //                 "horizontalOrigin": this.MarkerXOriginPos,
  //                 "distanceDisplayCondition":{
  //                     "distanceDisplayCondition":[this.Distance]
  //                 },
  //                 "image": this.MarkerPath,
  //                 "pixelOffset": {
  //                     "cartesian2": [
  //                         0, 0
  //                     ]
  //                 },
  //                 "scale": this.MaekerPixelSize,
  //                 "show": this.MarkerVisible,
  //                 "verticalOrigin": this.MarkerYOriginPos
  //             },
  //             "label": {
  //                 "fillColor": {
  //                     "rgba": this.MarkerColor
  //                 },
  //                 "font": "11pt Lucida Console",
  //                 "horizontalOrigin": "LEFT",
  //                 "pixelOffset": {
  //                     "cartesian2": [
  //                         10, 0
  //                     ]
  //                 },
  //                 "show": this.MarkerVisible,
  //                 "style": "FILL_AND_OUTLINE",
  //                 "text": this.name,
  //                 "verticalOrigin": "CENTER"
  //             },
  //             "path": {
  //                 "show": [
  //                     {
  //                         "interval": CZML_GENERALTOOLS_CLASS.HEU_ScenarioTime,
  //                         "boolean": this.OrbitVisible
  //                     }
  //                 ],
  //                 "width": this.OrbitLineWidth,
  //                 "material": CZML_GENERALTOOLS_CLASS.GetMaterialObject(this.OrbitLineStyle, this.OrbitColor),
  //                 "resolution": 120
  //             },
  //             "model": {
  //                 "gltf": this.Model3DPath,
  //                 "scale": this.ModelSize,
  //                 "distanceDisplayCondition":{
  //                     "distanceDisplayCondition":[0,this.Distance]
  //                 },
  //                 "show": this.ModelVisible,
  //                 "runAnimations": false,
  //                 "nodeTransformations": {
  //                     "zhengliuzhaoA": {
  //                         "scale": {
  //                             "epoch": this.zhengliuzhaoAStartTime,
  //                             "cartesian": [
  //                                 0.0, 1.0, 1.0, 1.0,
  //                                 100.0, 1.0, 1.0, 1.0,
  //                                 OverallSeconds,0,0,0
  //                             ]
  //                         },
  //                         "translation": {
  //                             "epoch": this.zhengliuzhaoAStartTime,
  //                             "cartesian": [
  //                                 0,0,  0, 0,
  //                                 100,300, -400, -300,
  //                                 1000,300, -4000, -300,
  //                                 OverallSeconds,300, -4000, -300
  //                             ]
  //                         }
  //                     },
  //                     "zhengliuzhaoB": {
  //                         "scale": {
  //                             "epoch": this.zhengliuzhaoBStartTime,
  //                             "cartesian": [
  //                                 0.0, 1.0, 1.0, 1.0,
  //                                 100.0, 1.0, 1.0, 1.0,
  //                                 OverallSeconds,0,0,0
  //                             ]
  //                         },
  //                         "translation": {
  //                             "epoch": this.zhengliuzhaoBStartTime,
  //                             "cartesian": [
  //                                 0,0,  0, 0,
  //                                 100,300, -400, -300,
  //                                 1000,300, -4000,-300,
  //                                 OverallSeconds,300, -4000,-300
  //                             ]
  //                         }
  //                     },
  //                     "xin01ji": {
  //                         "scale": {
  //                             "epoch": this.xin01jiStartTime,
  //                             "cartesian": [
  //                                 0.0, 1.0, 1.0, 1.0,
  //                                 100.0, 1.0, 1.0, 1.0,
  //                                 OverallSeconds,0,0,0
  //                             ]
  //                         },
  //                         "translation": {
  //                             "epoch": this.xin01jiStartTime,
  //                             "cartesian": [
  //                                 0,0,  0, 0,
  //                                 100,300, -350,-400,
  //                                 1000,300, -3500,-400,
  //                                 OverallSeconds,300, -3500,-400
  //                             ]
  //                         }
  //                     },
  //                     "xin02ji": {
  //                         "scale": {
  //                             "epoch": this.xin02jiStartTime,
  //                             "cartesian": [
  //                                 0.0, 1.0, 1.0, 1.0,
  //                                 100.0, 1.0, 1.0, 1.0,
  //                                 OverallSeconds,0,0,0
  //                             ]
  //                         },
  //                         "translation": {
  //                             "epoch": this.xin02jiStartTime,
  //                             "cartesian": [
  //                                 0,0,  0, 0,
  //                                 100,300, -350,-400,
  //                                 1000,300, -3500,-400,
  //                                 OverallSeconds,300, -3500,-400
  //                             ]
  //                         }
  //                     },
  //                     "zhutuiA": {
  //                         "scale": {
  //                             "epoch": this.zhutuiAStartTime,
  //                             "cartesian": [
  //                                 0.0, 1.0, 1.0, 1.0,
  //                                 //100.0, 1.0, 1.0, 1.0,
  //                                 OverallSeconds,0,0,0
  //                             ]
  //                         },
  //                         "translation": {
  //                             "epoch": this.zhutuiAStartTime,
  //                             "cartesian": [
  //                                 0,0,  0, 0,
  //                                 100,300, -400, -400,
  //                                 1000,300, -4000, -400,
  //                                 OverallSeconds,300,-4000,-400
  //                             ]
  //                         }
  //                     },
  //                     "zhutuiB": {
  //                         "scale": {
  //                             "epoch": this.zhutuiBStartTime,
  //                             "cartesian": [
  //                                 0.0, 1.0, 1.0, 1.0,
  //                                 100.0, 1.0, 1.0, 1.0,
  //                                 OverallSeconds,0,0,0
  //                             ]
  //                         },
  //                         "translation": {
  //                             "epoch": this.zhutuiBStartTime,
  //                             "cartesian": [
  //                                 0,0,  0, 0,
  //                                 100,300, -400, -400,
  //                                 1000,300, -4000, -400,
  //                                 OverallSeconds,300,-4000,-400
  //                             ]
  //                         }
  //                     },
  //                     "zhutuiC": {
  //                         "scale": {
  //                             "epoch": this.zhutuiCStartTime,
  //                             "cartesian": [
  //                                 0.0, 1.0, 1.0, 1.0,
  //                                 100.0, 1.0, 1.0, 1.0,
  //                                 OverallSeconds,0,0,0
  //                             ]
  //                         },
  //                         "translation": {
  //                             "epoch": this.zhutuiCStartTime,
  //                             "cartesian": [
  //                                 0,0,  0, 0,
  //                                 100,300, -400, -400,
  //                                 1000,300, -4000, -400,
  //                                 OverallSeconds,300,-4000,-400
  //                             ]
  //                         }
  //                     },
  //                     "zhutuiD": {
  //                         "scale": {
  //                             "epoch": this.zhutuiDStartTime,
  //                             "cartesian": [
  //                                 0.0, 1.0, 1.0, 1.0,
  //                                 100.0, 1.0, 1.0, 1.0,
  //                                 OverallSeconds,0,0,0
  //                             ]
  //                         },
  //                         "translation": {
  //                             "epoch":this.zhutuiDStartTime,
  //                             "cartesian": [
  //                                 0,0,  0, 0,
  //                                 100,300, -400, -400,
  //                                 1000,300, -4000, -400,
  //                                 OverallSeconds,300,-4000,-400
  //                             ]
  //                         }
  //                     },
  //                     "shangmianji": {
  //                         "scale": {
  //                             "epoch": this.shangmianjiStartTime,
  //                             "cartesian": [
  //                                 0.0, 1.0, 1.0, 1.0,
  //                                 100.0, 1.0, 1.0, 1.0,
  //                                 OverallSeconds,0,0,0
  //                             ]
  //                         },
  //                         "translation": {
  //                             "epoch":this.shangmianjiStartTime,
  //                             "cartesian": [
  //                                 0,0,  0, 0,
  //                                 100,300, -350,-400,
  //                                 1000,300, -3500,-400,
  //                                 OverallSeconds,300, -3500,-400
  //                             ]
  //                         }
  //                     },
  //                 }
  //             },
  //             "position": {
  //                 "interpolationAlgorithm": "LAGRANGE",
  //                 "interpolationDegree": 2,
  //                 "referenceFrame":this.ReferenceFrame,
  //                 "epoch": sOrbitStartTime,
  //                 "cartesian": this.position
  //             },
  //             "orientation": {
  //                 "interpolationAlgorithm": "LAGRANGE",
  //                 "interpolationDegree": 1,
  //                 "epoch": sOrbitStartTime,
  //                 "unitQuaternion": this.orientation
  //             }
  //         }
  //         return CZML_GENERALTOOLS_CLASS.InsertModelObjectInformation(this.id, OrbitObject, true);
  //     }
  // }
  // export default CZML_NonAnimatedModel
  constructor(
    viewer,
    id,
    name,
    OrbitStartTime,
    OrbitEndTime,
    position,
    orientation,
    ModelVisible,
    Model3DPath,
    ModelSize,
    MarkerVisible,
    MarkerPath,
    MaekerPixelSize,
    MarkerColor,
    MarkerXOriginPos,
    MarkerYOriginPos,
    OrbitVisible,
    OrbitLineStyle,
    OrbitLineWidth,
    OrbitColor,
    Distance,
    ReferenceFrame
  ) {
    this._viewer = viewer
    this.id = id
    this.name = name
    this.OrbitStartTime = OrbitStartTime
    this.OrbitEndTime = OrbitEndTime
    this.position = position
    this.orientation = orientation
    this.ModelVisible = ModelVisible
    this.Model3DPath = Model3DPath
    this.ModelSize = ModelSize
    this.MarkerVisible = MarkerVisible
    this.MarkerPath = MarkerPath
    this.MaekerPixelSize = MaekerPixelSize
    this.MarkerColor = MarkerColor
    this.MarkerXOriginPos = MarkerXOriginPos
    this.MarkerYOriginPos = MarkerYOriginPos
    this.OrbitVisible = OrbitVisible
    this.OrbitLineStyle = OrbitLineStyle
    this.OrbitLineWidth = OrbitLineWidth
    this.OrbitColor = OrbitColor
    this.Distance = Distance
    this.ReferenceFrame = ReferenceFrame
    this.CZML_AddSpacecraft()
  }

  CZML_AddSpacecraft() {
    const sOrbitStartTime = CZML_GENERALTOOLS_CLASS.Utcg2ISO8601TimeTransformation(this.OrbitStartTime)
    const sOrbitEndTime = CZML_GENERALTOOLS_CLASS.Utcg2ISO8601TimeTransformation(this.OrbitEndTime)
    const AvailabilityTime = sOrbitStartTime + "/" + sOrbitEndTime
    const JulianDateOfOrbitStartTime = Cesium.JulianDate.fromIso8601(sOrbitStartTime)
    const JulianDateOfOrbitEndTime = Cesium.JulianDate.fromIso8601(sOrbitEndTime)
    const OverallSeconds =
      (JulianDateOfOrbitEndTime.dayNumber - JulianDateOfOrbitStartTime.dayNumber) * 86400 +
      (JulianDateOfOrbitEndTime.secondsOfDay - JulianDateOfOrbitStartTime.secondsOfDay)
    const OrbitObject = {
      id: this.id,
      availability: AvailabilityTime,
      name: this.name,
      billboard: {
        eyeOffset: {
          cartesian: [0, 0, 0]
        },
        horizontalOrigin: this.MarkerXOriginPos,
        distanceDisplayCondition: {
          distanceDisplayCondition: [this.Distance]
        },
        image: this.MarkerPath,
        pixelOffset: {
          cartesian2: [0, 0]
        },
        scale: this.MaekerPixelSize,
        show: this.MarkerVisible,
        verticalOrigin: this.MarkerYOriginPos
      },
      label: {
        fillColor: {
          rgba: this.MarkerColor
        },
        font: "11pt Lucida Console",
        horizontalOrigin: "LEFT",
        pixelOffset: {
          cartesian2: [10, 0]
        },
        show: this.MarkerVisible,
        style: "FILL_AND_OUTLINE",
        text: this.name,
        verticalOrigin: "CENTER"
      },
      path: {
        show: [
          {
            interval: CZML_GENERALTOOLS_CLASS.HEU_ScenarioTime,
            boolean: this.OrbitVisible
          }
        ],
        width: this.OrbitLineWidth,
        material: CZML_GENERALTOOLS_CLASS.GetMaterialObject(this.OrbitLineStyle, this.OrbitColor),
        resolution: 120
      },
      model: {
        gltf: this.Model3DPath,
        scale: this.ModelSize,
        distanceDisplayCondition: {
          distanceDisplayCondition: [0, this.Distance]
        },
        show: this.ModelVisible,
        runAnimations: false
      },
      position: {
        interpolationAlgorithm: "LAGRANGE",
        interpolationDegree: 2,
        referenceFrame: this.ReferenceFrame,
        epoch: sOrbitStartTime,
        cartesian: this.position
      },
      orientation: {
        interpolationAlgorithm: "LAGRANGE",
        interpolationDegree: 1,
        epoch: sOrbitStartTime,
        unitQuaternion: this.orientation
      }
    }
    CZML_GENERALTOOLS_CLASS.InsertModelObjectInformation(this.id, OrbitObject, true)
    // ?????????????
    const idOther = [null]
    const vOrbitStartTime = [this.OrbitStartTime]
    const vOrbitEndTime = [this.OrbitEndTime]
    const pixel = new CZML_PIXEL_CLASS(this._viewer)
    pixel.CZML_PIXEL_AddCummunicationArc(this.id, idOther, this.OrbitVisible, vOrbitStartTime, vOrbitEndTime)
  }
}

export default CZML_NonAnimatedModel
